$.HOVERAUDIO = {};
$.HOVERAUDIO.replay = function () {
};
$.HOVERAUDIO.pause = function () {
}


var SOUNDS = {};
SOUNDS.stdVolume = 100;
SOUNDS.autoLoad = true;
SOUNDS.autoPlay = false;
SOUNDS.path = UTILS.rootPath + "audio/";
SOUNDS.generalExt = '.mp3';
SOUNDS.generalName = 'soundEvent_';
SOUNDS.generalNameCounter = 0;
SOUNDS.slideLayerName = 'slideSound';
SOUNDS.bgLayerName = 'bgSound';
SOUNDS.active = true;

soundManager.setup({
    url: 'js/vendor/audio/script/swf/',
    flashVersion: 9,
    useFlashBlock: false,
    wmode: null,
    noSWFCache: true,
    preferFlash: false,
    useHTML5Audio: true,
    onready: function () {


        //DEFINE GENERAL SFONDO EFFECT
        soundManager.createSound({
            id: SOUNDS.bgLayerName,
            url: SOUNDS.path + 'sfondo' + SOUNDS.generalExt,
            autoLoad: SOUNDS.autoLoad,
            autoPlay: true,
            loops: 999,
            onload: function () {
            },
            volume: SOUNDS.stdVolume
        });

        //DEFINE GENERAL HOVER EFFECT:0
        soundManager.createSound({
            id: SOUNDS.generalName + SOUNDS.generalNameCounter,
            url: SOUNDS.path + 'hover' + SOUNDS.generalExt,
            autoLoad: SOUNDS.autoLoad,
            autoPlay: SOUNDS.autoPlay,
            onload: function () {
                //alert('The sound '+this.id+' loaded!');
                //define event for play

                UTILS.getUserAgent();
                if (!UTILS.isDevice) {

                    $('body').on("mouseover", ".stdHover", function (e) {
                        soundManager.play(SOUNDS.generalName + '0');
                    });
                    $('body').on("mouseout", ".stdHover", function (e) {
                        soundManager.stop(SOUNDS.generalName + '0');
                    });
                    $('body').on("mouseover", ".stdHoverStiks", function (e) {
                        if ($('body').hasClass('home')) {
                            soundManager.play(SOUNDS.generalName + '0');
                        }
                    });
                    $('body').on("mouseout", ".stdHoverStiks", function (e) {
                        soundManager.stop(SOUNDS.generalName + '0');
                    });
                }
            },
            volume: SOUNDS.stdVolume
        });

        SOUNDS.generalNameCounter++;


    }
});

$('footer .audio').click(function () {
    SOUNDS.active = !SOUNDS.active;
    if (SOUNDS.active) {
        soundManager.resumeAll();
        $('footer .audio').removeClass('off');
    } else {
        soundManager.pauseAll();
        $('footer .audio').addClass('off');
    }
});